package com.biz.primus.app.erpbridge.controller;

import com.biz.primus.app.erpbridge.feign.CommodityFeignClient;
import com.biz.primus.base.support.rest.controller.BaseRestController;
import com.biz.primus.base.support.rest.vo.JsonResult;
import com.biz.primus.commodity.vo.SyncBrandVo;
import com.biz.primus.commodity.vo.SyncCategoryVo;
import com.biz.primus.commodity.vo.SyncCommoditySpecVo;
import com.biz.primus.commodity.vo.SyncCommodityVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author jiangnan
 * @Description:
 */
@RestController
@RequestMapping("bridge/commodity")
public class CommodityBridgeController extends BaseRestController {

    private final CommodityFeignClient commodityFeignClient;

    public CommodityBridgeController(CommodityFeignClient commodityFeignClient) {
        this.commodityFeignClient = commodityFeignClient;
    }

    @ApiOperation("同步商品主数据")
    @PostMapping("syncCommodities")
    JsonResult syncCommodities(@RequestBody List<SyncCommodityVo> reqVos){
        commodityFeignClient.syncCommodities(reqVos);
        return new JsonResult();
    }

    @ApiOperation("同步商品规格主数据")
    @PostMapping("syncCommoditySepcs")
    JsonResult syncCommoditySepcs(@RequestBody List<SyncCommoditySpecVo> reqVos){
        commodityFeignClient.syncCommoditySepcs(reqVos);
        return new JsonResult();
    }

    @ApiOperation("同步分类主数据")
    @PostMapping("syncCategories")
    JsonResult syncCategories(@RequestBody List<SyncCategoryVo> syncCategoryVos){
        commodityFeignClient.syncCategories(syncCategoryVos);
        return new JsonResult();
    }

    @ApiOperation("同步品牌主数据")
    @PostMapping("syncBrands")
    JsonResult syncBrands(@RequestBody List<SyncBrandVo> syncBrandVos){
        commodityFeignClient.syncBrands(syncBrandVos);
        return new JsonResult();
    }

}
